<?php include_once "top.php";
$stime=strtotime($_GET['sdate']);
$etime=strtotime($_GET['edate'])+86400;
$where='1';
if($stime && $etime){
	$where.=(' and create_time >= '.$stime.' and create_time < '.$etime);
}else{
	$where.=(' and create_time >= '.strtotime(date('Y-m-d',time())).' and create_time < '.strtotime(date('Y-m-d',time()+86400)));
}
$where.=' order by id desc';
?>
<div class="addleft">
	<a href="wishs.php">心愿单列表</a>
</div>
<div class="addbar">
	<ul>
	<h2 style="float:left">心愿单列表</h2>
	<div style="float:left;margin:20px 0 0 20px">
		<form action="wishs.php" method="get" onsubmit="return checkForm()">
		<input id="sdate" type="text" name="sdate" value="<?php echo $_GET['sdate']?$_GET['sdate']:date('Y-m-d',time())?>" class="laydate-icon ipt" onclick="laydate()" placeholder="选择开始日期" style="width:150px" /> -
		<input id="edate" type="text" name="edate" value="<?php echo $_GET['edate']?$_GET['edate']:date('Y-m-d',time())?>" class="laydate-icon ipt" onclick="laydate()" placeholder="选择结束日期" style="width:150px" />
		<input type="submit" name="sub_sch" value="查找" />
		<input type="button" name="" value="全部" onclick="location='wishs.php'" />
		</form>
	</div>
	<li class="lihd"><strong align="center">
		<label style="width:60px">ID</label>
		<label style="width:120px">用户姓名</label>
		<label style="width:400px">内容</label>
		<label style="width:120px">状态</label>
		<label style="width:150px">提交时间</label>
		</strong>
	</li>
	<?php 
	foreach($db->ig2_select('mae_wish_list',$where) as $list){
		$user=$db->ig2_want('mae_user','id='.$list['uid']);
	?>
	<li align="center">
		
		<label style="width:60px"><?php echo $list['id']?></label>
		<label style="width:120px"><?php echo $user?$user['name']:'该用户已被删除'?></label>
		<label style="width:400px"><?php echo trim($list['content'])?$list['content']:'-'?></label>
		<label style="width:120px"><?php switch($list['status']){
			case 0 : echo '未填写'; break;
			case 1 : echo '未实现'; break;
			case 2 : echo '已实现'; break;
			default : break;
		}?></label>
		<label style="width:150px"><?php echo date('Y-m-d H:i:s',$list['create_time'])?></label>
	</li>
	<?php }?>
	</ul>
</div>
<script language="javascript">
function trim(str){
	return str.replace(/(^\s*)|(\s*$)/g, "");
}
function checkForm(){
	var sdate=trim($('#sdate').val());
	var edate=trim($('#edate').val());
	if(sdate!='' && edate==''){
		alert('请选择结束日期');
		return false;
	}
	if(edate!='' && sdate==''){
		alert('请选择开始日期');
		return false;
	}
	return true;
}
</script>
<?php include_once "down.php";?>